package com.bdqn.easybuy1.utils;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Setter
@Getter
public class Pager implements Serializable {
    /**
     * 当前页码，从1开始，不是从0开始的索引
     */
    private int currentPage;
    /**
     * 总条数，表示查询到的数据条数
     */
    private int rowCount;
    /**
     * 每页显示的数据条数
     */
    private int rowPerPage;
    /**
     * 总页数
     */
    private int pageCount;
    private String url;

    public Pager(int rowCount, int rowPerPage, int currentPage) {
        this.rowCount = rowCount;
        this.rowPerPage = rowPerPage;
        this.currentPage = currentPage;
        if (this.rowCount % this.rowPerPage == 0) {
            this.pageCount = this.rowCount / this.rowPerPage;
        } else if (this.rowCount % this.rowPerPage > 0) {
            this.pageCount = this.rowCount / this.rowPerPage + 1;
        } else {
            this.pageCount = 0;
        }
    }
}
